package androidx.activity;

import android.os.Build.VERSION;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import androidx.annotation.CallSuper;
import androidx.annotation.LayoutRes;
import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import o.ai;
import o.kp;
import o.kp.c;
import o.kp.e;
import o.kq;
import o.kv;
import o.kx;
import o.ky;
import o.lg;
import o.lh;
import o.mr;
import o.my;
import o.na;

public class ComponentActivity extends androidx.core.app.ComponentActivity implements kv, lg, my, ai {
    private final na ˊ = na.ॱ(this);
    private lh ˋ;
    private final OnBackPressedDispatcher ˎ = new OnBackPressedDispatcher(new Runnable(this) {
        final /* synthetic */ ComponentActivity ˎ;

        {
            this.ˎ = r1;
        }

        public void run() {
            super.onBackPressed();
        }
    });
    private final kx ˏ = new kx(this);
    @LayoutRes
    private int ॱ;

    static final class b {
        Object ˊ;
        lh ॱ;

        b() {
        }
    }

    public ComponentActivity() {
        if (ac_() == null) {
            throw new IllegalStateException("getLifecycle() returned null in ComponentActivity's constructor. Please make sure you are lazily constructing your Lifecycle in the first call to getLifecycle() rather than relying on field initialization.");
        }
        if (VERSION.SDK_INT >= 19) {
            ac_().ॱ(new kq(this) {
                final /* synthetic */ ComponentActivity ˎ;

                {
                    this.ˎ = r1;
                }

                public void ˊ(@NonNull kv kvVar, @NonNull e eVar) {
                    if (eVar == e.ON_STOP) {
                        Window window = this.ˎ.getWindow();
                        View peekDecorView = window != null ? window.peekDecorView() : null;
                        if (peekDecorView != null) {
                            peekDecorView.cancelPendingInputEvents();
                        }
                    }
                }
            });
        }
        ac_().ॱ(new kq(this) {
            final /* synthetic */ ComponentActivity ॱ;

            {
                this.ॱ = r1;
            }

            public void ˊ(@NonNull kv kvVar, @NonNull e eVar) {
                if (eVar == e.ON_DESTROY && !this.ॱ.isChangingConfigurations()) {
                    this.ॱ.U_().ˏ();
                }
            }
        });
        if (19 <= VERSION.SDK_INT && VERSION.SDK_INT <= 23) {
            ac_().ॱ(new ImmLeaksCleaner(this));
        }
    }

    public void onCreate(@Nullable Bundle bundle) {
        super.onCreate(bundle);
        this.ˊ.ˏ(bundle);
        ky.ˋ(this);
        if (this.ॱ != 0) {
            setContentView(this.ॱ);
        }
    }

    @CallSuper
    public void onSaveInstanceState(@NonNull Bundle bundle) {
        kp ac_ = ac_();
        if (ac_ instanceof kx) {
            ((kx) ac_).ˊ(c.CREATED);
        }
        super.onSaveInstanceState(bundle);
        this.ˊ.ˎ(bundle);
    }

    @Nullable
    public final Object onRetainNonConfigurationInstance() {
        Object T_ = T_();
        lh lhVar = this.ˋ;
        if (lhVar == null) {
            b bVar = (b) getLastNonConfigurationInstance();
            if (bVar != null) {
                lhVar = bVar.ॱ;
            }
        }
        if (lhVar == null && T_ == null) {
            return null;
        }
        Object bVar2 = new b();
        bVar2.ˊ = T_;
        bVar2.ॱ = lhVar;
        return bVar2;
    }

    @Deprecated
    @Nullable
    public Object T_() {
        return null;
    }

    @Deprecated
    @Nullable
    public Object ab_() {
        b bVar = (b) getLastNonConfigurationInstance();
        return bVar != null ? bVar.ˊ : null;
    }

    @NonNull
    public kp ac_() {
        return this.ˏ;
    }

    @NonNull
    public lh U_() {
        if (getApplication() == null) {
            throw new IllegalStateException("Your activity is not yet attached to the Application instance. You can't request ViewModel before onCreate call.");
        }
        if (this.ˋ == null) {
            b bVar = (b) getLastNonConfigurationInstance();
            if (bVar != null) {
                this.ˋ = bVar.ॱ;
            }
            if (this.ˋ == null) {
                this.ˋ = new lh();
            }
        }
        return this.ˋ;
    }

    @MainThread
    public void onBackPressed() {
        this.ˎ.ˏ();
    }

    @NonNull
    public final OnBackPressedDispatcher ॱ() {
        return this.ˎ;
    }

    @NonNull
    public final mr V_() {
        return this.ˊ.ˏ();
    }
}
